#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtMqtt/qmqttclient.h>
#include <QtMqtt/qmqttsubscription.h>
#include <QNetworkAccessManager>
#include <QPushButton>
#include "TilemapView.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    virtual void mousePressEvent(QMouseEvent *);
    virtual void mouseMoveEvent(QMouseEvent *);
    virtual void mouseReleaseEvent(QMouseEvent *);

private:
    Ui::MainWindow *ui;
    QMqttClient *client;
    TilemapView *tv;
    bool is_connect;
    QString host;
    QString port;
    QString map_name;
    QString robot_did;
    QString robot_pid;
    QNetworkAccessManager* manager;
    bool need_move;
    QPoint m_pos;

    void clickedConnectButton();
    void connected();
    void viewInit(QString name);
    void subscribeMessage();
    void handleSubscribePoseMessage(const QMqttMessage &);
    void handleSubscribeTrackMessage(const QMqttMessage &);
};
#endif // MAINWINDOW_H
